package com.example.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.domain.Banner;
import com.example.domain.Category;
import com.example.domain.MovieCategory;
import com.example.domain.model.BannerDTO;
import com.example.service.BannerService;
import com.example.mapper.BannerMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author Administrator
* @description 针对表【banner】的数据库操作Service实现
* @createDate 2023-03-20 09:43:41
*/
@Service
public class BannerServiceImpl extends ServiceImpl<BannerMapper, Banner> implements BannerService{

    @Autowired
    private BannerMapper bannerMapper;

    @Override
    public IPage<BannerDTO> getList(Page<Banner> page) {
        return bannerMapper.selectBannerList(page);
    }

    @Override
    public Banner getById(String id) {
        return bannerMapper.selectById(id);
    }

    @Override
    public boolean save(Banner banner) {
        return bannerMapper.insert(banner) > 0;
    }

    @Override
    public boolean update(String id, Banner banner) {
        Banner banner1 = bannerMapper.selectById(id);
        if (banner1 != null){
            banner.setId(id);
            return bannerMapper.updateById(banner) > 0;
        }
        return false;
    }

    @Override
    public boolean delete(String id) {

        return false;
    }
}




